﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace Acme.BookStore2.Migrations
{
    public partial class workschedule : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "AppWorkSchedule",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    ExtraProperties = table.Column<string>(nullable: true),
                    ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Title = table.Column<string>(maxLength: 128, nullable: true),
                    Description = table.Column<string>(maxLength: 512, nullable: true),
                    WorkType = table.Column<string>(nullable: true),
                    Remark = table.Column<string>(nullable: true),
                    TenantId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppWorkSchedule", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "AppWorkScheduleItem",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorId = table.Column<Guid>(nullable: true),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierId = table.Column<Guid>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false, defaultValue: false),
                    DeleterId = table.Column<Guid>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Stage = table.Column<string>(maxLength: 128, nullable: true),
                    Route = table.Column<string>(maxLength: 128, nullable: true),
                    Lane = table.Column<int>(nullable: false),
                    Spot = table.Column<int>(nullable: false),
                    Sort = table.Column<int>(nullable: false),
                    Driver = table.Column<Guid>(nullable: true),
                    RegisterVehicleId = table.Column<Guid>(nullable: true),
                    RegisterTime = table.Column<DateTime>(nullable: true),
                    RegisterStatus = table.Column<int>(nullable: false),
                    Remark = table.Column<string>(nullable: true),
                    WorkScheduleId = table.Column<Guid>(nullable: false),
                    TenantId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_AppWorkScheduleItem", x => x.Id);
                    table.ForeignKey(
                        name: "FK_AppWorkScheduleItem_AppWorkSchedule_WorkScheduleId",
                        column: x => x.WorkScheduleId,
                        principalTable: "AppWorkSchedule",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AppWorkScheduleItem_WorkScheduleId",
                table: "AppWorkScheduleItem",
                column: "WorkScheduleId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "AppWorkScheduleItem");

            migrationBuilder.DropTable(
                name: "AppWorkSchedule");
        }
    }
}
